
{extend name="layout"}
{block name="detail"}
<header class="aui-header-default aui-header-fixed aui-header-bg">
    <div class="aui-car-white-Typeface" style="width:100%;">申请退款</div>
</header>
<section class="aui-myOrder-content" style="padding: 10px;margin-top: 30px;">
    <form action="{:url('index/center/saveRefund')}" method="post" id="refundForm" enctype="multipart/form-data">
        <input type="hidden" name="orderId" value="{$order.id}">
        <div class="form-group row">
            <label for="refundType" class="col-sm-3 form-control-label text-center">申请类型</label>
            <div class="col-sm-9">
                <select name="refundType" class="form-control" id="refundType" >
                    <option value="退货退款">我要退货退款</option>
                    <option value="仅退款">我要退款不退货</option>
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label for="refundReason" class="col-sm-3 form-control-label text-center">退款原因</label>
            <div class="col-sm-9">
                <select name="refundReason" class="form-control" id="refundReason" >
                    <option value="多拍、错拍、不想要">多拍、错拍、不想要</option>
                    <option value="不喜欢、效果不好">不喜欢、效果不好</option>
                    <option value="商品描述与事实不符">商品描述不符</option>
                    <option value="质量问题">质量问题</option>
                    <option value="假货">假货</option>
                    <option value="其他">其他</option>
                </select>
            </div>
        </div>

        <div class="form-group row">
            <label for="info" class="col-sm-3 form-control-label  text-center">退款说明</label>
            <div class="col-sm-9">
                <textarea name="info" id="info" class="form-control" ></textarea>
            </div>
        </div>

        <div class="form-group row">
            <label for="refundFee" class="col-sm-3 form-control-label  text-center">退款金额</label>
            <div class="col-sm-9">
                <input id="refundFee" type="text" required name="refundFee" value="{$order.totalFee/100}" class="form-control" >
            </div>
        </div>
        <div class="form-group row">
            <label for="imghead" class="col-sm-3 form-control-label  text-center">图片</label>
            <div class="col-sm-9">
                <div id="preview">
                    <img id="imghead" src="__STATIC__/ui/shop/images/add.png" style=" width:40px;" onclick="$('#previewImg').click();">
                </div>
                <input type="file" name="img" accept="image/*" multiple onchange="previewImage(this,40,40,'preview','imghead','previewImg')" style="display: none;" id="previewImg">
                {include file="common/upload_imgs"/}
            </div>
        </div>

        <div class="form-group" style="text-align:center;">
            <input  type="button" onclick="saveRefund()" value="提交" class="btn btn-primary">
        </div>
    </form>
</section>
<div style="height:100px;"></div>
<script>
    function saveRefund() {
       var payFee =  "{$order.totalFee}";
       var refundFee =  $.trim($("#refundFee").val()) ;
       if(refundFee){
           refundFee = 100*refundFee;
           if(refundFee-payFee>0){
               layer.alert('退款金额不能大于'+payFee/100+'元');
           }
           else{
               $("#refundForm").submit();
           }
       }
       else{
           layer.alert('请填写退款金额');
       }
    }
</script>
{/block}